package com.zjun.core.snowflake;

import org.springframework.beans.factory.InitializingBean;

public class RandomWorkIdChoose extends AbstractWorkIdChooseTemplate implements InitializingBean {
    @Override
    protected WorkWrapper chooseWorkId() {
        int start=0,end = 31;
        return new WorkWrapper(getRandom(start,end),getRandom(start,end));
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        chooseWorkId();
    }
    private static long getRandom(int start,int end){
        long random = (long) (Math.random()*(end-start -1) +start);
        return random;
     }
}
